package com.xhorse.lockplatform.comm.constant;

import com.xhorse.lockplatform.comm.enums.ResultEnum;

/**
 * @author Think
 */
public class CommonResult {
    /**
     * 应答码（默认值为操作成功）
     */
    private String code = ResultEnum.SUCCESS.getCode();
    /**
     * 应答码描述（默认值为操作成功）
     */
    private String msg = ResultEnum.SUCCESS.getMsg();
    /**
     * 应答数据体（可以为空）
     */
    private Object data = null;

    public CommonResult() {
    }

    /**
     * 返回的操作码为ResultEnum.SUCCESS
     */
    public CommonResult(Object data) {
        this(ResultEnum.SUCCESS, data);
    }

    public CommonResult(ResultEnum codeEnum, Object data) {
        this(codeEnum.getCode(), codeEnum.getMsg(), data);
    }

    /**
     * 返回的data=""
     */
    public CommonResult(ResultEnum codeEnum) {
        this(codeEnum.getCode(), codeEnum.getMsg());
    }

    /**
     * 返回的data=""
     */
    public CommonResult(String code, String msg) {
        this(code, msg, "");
    }

    public CommonResult(String code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}